﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RealEstateAgencyDAL;
using System.Collections.ObjectModel;
using RealEstateBrowser.Helpers;

namespace RealEstateBrowser.ViewModels
{
    public class TownViewModel : ViewModelBase
    {
        private Town town;
        private ObservableCollection<DistrictViewModel> districts;

        public TownViewModel()
        {
        }

        public ObservableCollection<DistrictViewModel> Districts
        {
            get
            {
                return districts;
            }
            set
            {
                if (this.districts != value)
                {
                    districts = value;
                    OnPropertyChanged("Districts");
                }
            }
        }

        public Town Town
        {
            get
            {
                return town;
            }
            set
            {
                if (this.town != value)
                {
                    town = value;
                    this.Districts = new ObservableCollection<DistrictViewModel>
                        (Skochubra.CreateDisrictViewModelCollection(town.Locations));
                    OnPropertyChanged("Town");
                }
            }
        }

        public string TownName
        {
            get
            {
                return this.Town.TownName;
            }
            set
            {
                if (this.town.TownName != value)
                {
                    this.town.TownName = value;
                    OnPropertyChanged("TownName");
                }
            }
        }
    }
}